home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / U-Z / YACC / yyless.c < prev    next >
Encoding:
Text File  |  1990-11-05  |  941 b   |  39 lines  |  [TEXT/KAHL]

  1. /*
  2.   HEADER: CUG     nnn.nn;
  3.   TITLE:     YACC - Yet Another Compilier-Compilier
  4.   VERSION:     1.0 for IBM-PC
  5.   DATE:      JAN 28, 1985
  6.   DESCRIPTION:     LALR(1) Parser Generator. From UNIX
  7.   KEYWORDS:     Parser Generator Compilier-Compilier YACC
  8.   SYSTEM:     IBM-PC and Compatiables
  9.   FILENAME:      YYLESS.C
  10.   WARNINGS:     This program is not for the casual user. It will
  11.          be useful primarily to expert developers.
  12.   CRC:         N/A
  13.   SEE-ALSO:     LEX and PREP
  14.   AUTHORS:     Scott Guthery 11100 leafwood lane Austin, TX 78750
  15.   COMPILERS:     DESMET-C
  16.   REFERENCES:     UNIX Systems Manuals
  17. */
  18.  
  19. yyless(x) int x;
  20.  
  21.    {
  22.    extern char yytext[];
  23.    register char *lastch, *ptr;
  24.    extern int yyleng;
  25.    extern int yyprevious;
  26.  
  27.    lastch = yytext+yyleng;
  28.    if (x>=0 && x <= yyleng)
  29.       ptr = x + yytext;
  30.    else
  31.       ptr = x;
  32.    while (lastch > ptr)
  33.       yyunput(*--lastch);
  34.    *lastch = 0;
  35.    if (ptr >yytext)
  36.       yyprevious = *--lastch;
  37.    yyleng = ptr-yytext;
  38.    }
  39.